﻿using System;

namespace unitlib
{
    /// <summary>
    /// 压力单位，帕斯卡
    /// </summary>
    public readonly struct Unit_Pa : IUnit
    {
        public double Value { get; }
        public string Unit => "Pa";

        public string LatexUnit => "\\mathrm{Pa}";

        public Unit_Pa(double value) { Value = value; }
        public Unit_Pa Round(int digits) => new Unit_Pa(Math.Round(Value, digits));
        //数值与字符串转换
        public override string ToString() => Value.ToString();
        public static explicit operator Unit_Pa(double value) => new Unit_Pa(value);
        public static explicit operator double(Unit_Pa value) => value.Value;
        public static implicit operator Unit_Pa(string value) => new Unit_Pa(value.Parse());
        //比较运算
        public static bool operator ==(Unit_Pa left, Unit_Pa right) => left.Equals(right);
        public static bool operator !=(Unit_Pa left, Unit_Pa right) => !left.Equals(right);
        public override bool Equals(object obj) => obj is Unit_Pa other && other.Value == Value;
        public override int GetHashCode()
        {
            unchecked
            {
                return GetType().GetHashCode() * 31 + Value.GetHashCode();
            }
        }
        //常规运算
        public static Unit_Pa operator +(Unit_Pa left, Unit_Pa right) => new Unit_Pa(left.Value + right.Value);
        public static Unit_Pa operator -(Unit_Pa left, Unit_Pa right) => new Unit_Pa(left.Value - right.Value);
        public static Unit_Pa operator *(Unit_Pa left, UnitValue right) => new Unit_Pa(left.Value * right.Value);
        public static Unit_Pa operator *(UnitValue left, Unit_Pa right) => new Unit_Pa(left.Value * right.Value);
        public static Unit_Pa operator /(Unit_Pa left, UnitValue right) => new Unit_Pa(left.Value / right.Value);
        public static UnitValue operator /(Unit_Pa left, Unit_Pa right) => new UnitValue(left.Value / right.Value);
        //新增运算  
    }





}
